package com.iot.device.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iot.device.mapper.QuakeClientMapper;
import com.iot.device.domain.QuakeClient;
import com.iot.device.service.IQuakeClientService;

/**
 * 震动监测设备Service业务层处理
 * 
 * @author iot
 * @date 2023-04-14
 */
@Service
public class QuakeClientServiceImpl implements IQuakeClientService 
{
    @Autowired
    private QuakeClientMapper quakeClientMapper;

    /**
     * 查询震动监测设备
     * 
     * @param id 震动监测设备主键
     * @return 震动监测设备
     */
    @Override
    public QuakeClient selectQuakeClientById(Long id)
    {
        return quakeClientMapper.selectQuakeClientById(id);
    }

    /**
     * 查询震动监测设备列表
     * 
     * @param quakeClient 震动监测设备
     * @return 震动监测设备
     */
    @Override
    public List<QuakeClient> selectQuakeClientList(QuakeClient quakeClient)
    {
        return quakeClientMapper.selectQuakeClientList(quakeClient);
    }

    /**
     * 新增震动监测设备
     * 
     * @param quakeClient 震动监测设备
     * @return 结果
     */
    @Override
    public int insertQuakeClient(QuakeClient quakeClient)
    {
        return quakeClientMapper.insertQuakeClient(quakeClient);
    }

    /**
     * 修改震动监测设备
     * 
     * @param quakeClient 震动监测设备
     * @return 结果
     */
    @Override
    public int updateQuakeClient(QuakeClient quakeClient)
    {
        return quakeClientMapper.updateQuakeClient(quakeClient);
    }

    /**
     * 批量删除震动监测设备
     * 
     * @param ids 需要删除的震动监测设备主键
     * @return 结果
     */
    @Override
    public int deleteQuakeClientByIds(Long[] ids)
    {
        return quakeClientMapper.deleteQuakeClientByIds(ids);
    }

    /**
     * 删除震动监测设备信息
     * 
     * @param id 震动监测设备主键
     * @return 结果
     */
    @Override
    public int deleteQuakeClientById(Long id)
    {
        return quakeClientMapper.deleteQuakeClientById(id);
    }

    @Override
    public QuakeClient selectQuakeClientByClientNo(String clientNo) {
        return quakeClientMapper.selectQuakeClientByClientNo(clientNo);
    }

    @Override
    public Set<String> selectQuakeClientNosByUserId(Long userId) {
        return quakeClientMapper.selectQuakeClientNosByUserId(userId);
    }

    @Override
    public Map<String, Long> countQuakeClientsByUserId(Long userId) {
        return quakeClientMapper.countQuakeClientsByUserId(userId);
    }

    @Override
    public Map<String, Long> selectQuakeClientStatistics(Long userId) {
        Map<String, Long> map = quakeClientMapper.selectQuakeClientStatistics(userId);
        if(map == null){
            map = new HashMap<>();
            map.put("onlineCount", 0L);
            map.put("totalCount", 0L);
        }
        return map;
    }
}
